package demo.huodongbaoming.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 健康检查控制器
 * 用于Consul服务健康检查
 */
@RestController
public class HealthCheckController {

    @Value("${spring.application.name:activity-service}")
    private String applicationName;

    @Value("${server.port:8085}")
    private int serverPort;

    /**
     * 自定义健康检查端点
     * @return 健康状态信息
     */
    @GetMapping("/api/health")
    public Map<String, Object> healthCheck() {
        Map<String, Object> health = new HashMap<>();
        health.put("status", "UP");
        health.put("service", applicationName);
        health.put("port", serverPort);
        health.put("timestamp", System.currentTimeMillis());
        return health;
    }
} 